GDK W32: Refuse to release mouse grab while in DnD mode
authorРуслан Ижбулатов <lrn1986@gmail.com>
Thu, 14 Sep 2017 17:43:38 +0000 (17:43 +0000)
committerРуслан Ижбулатов <lrn1986@gmail.com>
Sat, 2 Dec 2017 10:38:36 +0000 (10:38 +0000)
Handle WM_CANCELMODE and do nothing in response to it when DnD is
active. Otherwise pass it to DefWindowProc, which will call ReleaseCapture()
on our behalf.
This prevents us from losing mouse capture when alt-tabbing during DnD
(this includes the feature of Windows Explorer where dragging stuff over
a window button in the taskbar causes that window to receive focus, i.e.
keyboardless alt-tabbing).

https://bugzilla.gnome.org/show_bug.cgi?id=786509

gdk/win32/gdkevents-win32.c

index 7b459db782b7f8ac78c64b857f3d9f3deb59d611..601ca036c87ac2c4cc0266aefae655db52ae1140 100644 (file)
@@ -3281,6 +3281,23 @@ gdk_event_translate (MSG  *msg,
 
       break;
 
+    /*
+     * Handle WM_CANCELMODE and do nothing in response to it when DnD is
+     * active. Otherwise pass it to DefWindowProc, which will call ReleaseCapture()
+     * on our behalf.
+     * This prevents us from losing mouse capture when alt-tabbing during DnD
+     * (this includes the feature of Windows Explorer where dragging stuff over
+     * a window button in the taskbar causes that window to receive focus, i.e.
+     * keyboardless alt-tabbing).
+     */
+    case WM_CANCELMODE:
+      if (_modal_operation_in_progress & GDK_WIN32_MODAL_OP_DND)
+        {
+          return_val = TRUE;
+          *ret_valp = 0;
+        }
+      break;
+
     case WM_CAPTURECHANGED:
       /* Sometimes we don't get WM_EXITSIZEMOVE, for instance when you
         select move/size in the menu and then click somewhere without